<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${action == 'add' ? '添加学生' : '编辑学生'}"></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background-color: #fff;
            padding: 40px 50px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 400px;
        }
        h1 {
            color: #333;
            text-align: center;
            margin-bottom: 30px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-weight: bold;
        }
        .form-group input[type="text"],
        .form-group input[type="number"],
        .form-group select {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 16px;
        }
        .form-group input[type="radio"] {
            margin-right: 5px;
        }
        .button-group {
            text-align: center;
            margin-top: 30px;
        }
        .button-group button {
            background-color: #007bff;
            color: white;
            padding: 12px 25px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            margin: 0 10px;
        }
        .button-group button:hover {
            background-color: #0056b3;
        }
        .button-group a {
            display: inline-block;
            background-color: #6c757d;
            color: white;
            padding: 12px 25px;
            border-radius: 4px;
            text-decoration: none;
            font-size: 16px;
            margin: 0 10px;
        }
        .button-group a:hover {
            background-color: #5a6268;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1 th:text="${action == 'add' ? '添加学生' : '编辑学生'}"></h1>
        <form th:action="${action == 'add' ? '/students/add' : '/students/edit'}" th:object="${student}" method="post">
            <input type="hidden" th:field="*{id}" th:if="${action == 'edit'}" />

            <div class="form-group">
                <label for="studentId">学号:</label>
                <input type="text" id="studentId" th:field="*{studentId}" required />
            </div>

            <div class="form-group">
                <label for="name">姓名:</label>
                <input type="text" id="name" th:field="*{name}" required />
            </div>

            <div class="form-group">
                <label for="age">年龄:</label>
                <input type="number" id="age" th:field="*{age}" required min="1" max="100" />
            </div>

            <div class="form-group">
                <label>性别:</label>
                <input type="radio" id="genderMale" th:field="*{gender}" value="男" required />
                <label for="genderMale">男</label>
                <input type="radio" id="genderFemale" th:field="*{gender}" value="女" />
                <label for="genderFemale">女</label>
            </div>

            <div class="form-group">
                <label for="major">专业:</label>
                <input type="text" id="major" th:field="*{major}" required />
            </div>

            <div class="button-group">
                <button type="submit" th:text="${action == 'add' ? '添加' : '更新'}"></button>
                <a th:href="@{/students}">取消</a>
            </div>
        </form>
    </div>
</body>
</html> 